package org.example.aidemo.controller;

import org.example.aidemo.pojo.Result;
import org.example.aidemo.service.common.AiChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/ai")
public class AiChatController {

    @Autowired
    private AiChatService aiChatService;

    @GetMapping(value = "/chat", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<String> chat(@RequestParam String message) {
        String response = aiChatService.chatWithFunctions(message);
        return Result.success(response);
    }

}